﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace YoutubeGetter
{
    public partial class SettingsForm : Form
    {
        public SettingsForm()
        {
            InitializeComponent();
        }

		private void SettingsForm_Load(object sender, EventArgs e)
		{
			txtDownloadLocation.Text = YoutubeTools.downloadLocation;
			chkSubFolders.Checked = YoutubeTools.useSubFolders;
			txtMaxDownloads.Text = YoutubeTools.maxDownloads.ToString();
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			this.Close();
		}

		private void btnSelectLocation_Click(object sender, EventArgs e)
		{
			FolderBrowserDialog dialog = new FolderBrowserDialog();
			dialog.Description = "Select a location to save your videos to";
			dialog.RootFolder = Environment.SpecialFolder.MyComputer;
			dialog.ShowNewFolderButton = true;
			if (dialog.ShowDialog() == DialogResult.OK)
			{
				txtDownloadLocation.Text = dialog.SelectedPath;
			}
		}

		private void btnSave_Click(object sender, EventArgs e)
		{
			YoutubeTools.downloadLocation = txtDownloadLocation.Text;
			YoutubeTools.useSubFolders = chkSubFolders.Checked;
			YoutubeTools.maxDownloads = Convert.ToInt32(txtMaxDownloads.Text);
			this.Close();
		}
    }
}
